<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>dbcloud: MongoDB Development Manual</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="csmake.v2.100.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">dbcloud
   &#160;<span id="projectnumber">1.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('mongo.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">MongoDB Development Manual </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><div class="image">
<img src="https://avatars1.githubusercontent.com/u/17017373?s=460&v=4" alt="webmongo"/>
</div>
<h1>webmongo</h1>
<h2>About us</h2>
<p>Accessing server-side mongodb through client javascript API. This project is a branch of <a href="https://github.com/csmake/dbcloud">dbcloud</a></p>
<p>You can do almost invoke on mongodb through the javascript API in browser.</p>
<p>The client javascript api support <code>IE6.0+ Chrome FireFox and Wechat</code></p>
<p>web: <a href="http://mongo.dbcloud.org">http://mongo.dbcloud.org</a></p>
<p>mail: <a href="#" onclick="location.href='mai'+'lto:'+'web'+'mo'+'ngo'+'@c'+'sma'+'ke'+'.co'+'m'; return false;">webmo<span style="display: none;">.nosp@m.</span>ngo@<span style="display: none;">.nosp@m.</span>csmak<span style="display: none;">.nosp@m.</span>e.co<span style="display: none;">.nosp@m.</span>m</a></p>
<h2>Application scenarios</h2>
<p>Rapid prototyping does not need to write server-side code.</p>
<p>Academic teaching and research, WYSIWYG</p>
<p>Enterprise internal application</p>
<p>Other applications that do not focus on the security of the database table structure.</p>
<h2>Start the basic project</h2>
<ol type="1">
<li>Run mongod first.</li>
<li>Put webmongo.war in your servlet server webapps ,Apache Tomcat8.0 , Glass Fish Server4.x and so on.</li>
<li>Open browser(Chrome FireFox IE) and put <a href="http://localhost:8080/webmongo/,">http://localhost:8080/webmongo/,</a> The address may be different depending on your settings</li>
</ol>
<h2>Start to write your web application</h2>
<ol type="1">
<li>Copy <a class="el" href="_mongo_collection_8java_source.html">MongoCollection.java</a> and <a class="el" href="_mongo_collection_servlet_8java_source.html">MongoCollectionServlet.java</a> from webmongo.war /src/java/.. , into your src/java/org/dbcloud/mongodb</li>
<li>Copy all *.js files in webmongo.war /js to your js directory. JQuery is necessary. IE6.0 need to use the 1.x version and json2.js is necessary.</li>
<li>Edit the web.xml, like this: <div class="fragment"><div class="line">&lt;<span class="keywordtype">servlet</span>&gt;</div><div class="line">    &lt;<span class="keywordtype">servlet-name</span>&gt;<span class="keyword">MongoCollectionServlet</span>&lt;/<span class="keywordtype">servlet-name</span>&gt;</div><div class="line">    &lt;<span class="keywordtype">servlet-class</span>&gt;<span class="keyword">org.dbcloud.mongodb.MongoCollectionServlet</span>&lt;/<span class="keywordtype">servlet-class</span>&gt;</div><div class="line">    &lt;<span class="keywordtype">init-param</span>&gt;</div><div class="line">        &lt;<span class="keywordtype">param-name</span>&gt;<span class="keyword">dbhost</span>&lt;/<span class="keywordtype">param-name</span>&gt;</div><div class="line">        &lt;<span class="keywordtype">param-value</span>&gt;127.0.0.1&lt;/<span class="keywordtype">param-value</span>&gt;</div><div class="line">    &lt;/<span class="keywordtype">init-param</span>&gt;</div><div class="line">    &lt;<span class="keywordtype">init-param</span>&gt;</div><div class="line">        &lt;<span class="keywordtype">param-name</span>&gt;<span class="keyword">dbport</span>&lt;/<span class="keywordtype">param-name</span>&gt;</div><div class="line">        &lt;<span class="keywordtype">param-value</span>&gt;27017&lt;/<span class="keywordtype">param-value</span>&gt;</div><div class="line">    &lt;/<span class="keywordtype">init-param</span>&gt; </div><div class="line">    &lt;<span class="keywordtype">init-param</span>&gt;</div><div class="line">        &lt;<span class="keywordtype">param-name</span>&gt;<span class="keyword">db</span>&lt;/<span class="keywordtype">param-name</span>&gt;</div><div class="line">        &lt;<span class="keywordtype">param-value</span>&gt;<span class="keyword">test</span>&lt;/<span class="keywordtype">param-value</span>&gt;</div><div class="line">    &lt;/<span class="keywordtype">init-param</span>&gt;</div><div class="line">    &lt;<span class="keywordtype">init-param</span>&gt;</div><div class="line">        &lt;<span class="keywordtype">param-name</span>&gt;<span class="keyword">connection</span>&lt;/<span class="keywordtype">param-name</span>&gt;</div><div class="line">        &lt;<span class="keywordtype">param-value</span>&gt;<span class="keyword">test</span>&lt;/<span class="keywordtype">param-value</span>&gt;</div><div class="line">    &lt;/<span class="keywordtype">init-param</span>&gt;</div><div class="line">    &lt;<span class="keywordtype">init-param</span>&gt;</div><div class="line">        &lt;<span class="keywordtype">param-name</span>&gt;<span class="keyword">user</span>&lt;/<span class="keywordtype">param-name</span>&gt;</div><div class="line">        &lt;<span class="keywordtype">param-value</span>&gt;&lt;/<span class="keywordtype">param-value</span>&gt;</div><div class="line">    &lt;/<span class="keywordtype">init-param</span>&gt;</div><div class="line">    &lt;<span class="keywordtype">init-param</span>&gt;</div><div class="line">        &lt;<span class="keywordtype">param-name</span>&gt;<span class="keyword">password</span>&lt;/<span class="keywordtype">param-name</span>&gt;</div><div class="line">        &lt;<span class="keywordtype">param-value</span>&gt;&lt;/<span class="keywordtype">param-value</span>&gt;</div><div class="line">    &lt;/<span class="keywordtype">init-param</span>&gt; </div><div class="line">&lt;/<span class="keywordtype">servlet</span>&gt;</div><div class="line">&lt;<span class="keywordtype">servlet-mapping</span>&gt;</div><div class="line">    &lt;<span class="keywordtype">servlet-name</span>&gt;<span class="keyword">MongoCollectionServlet</span>&lt;/<span class="keywordtype">servlet-name</span>&gt;</div><div class="line">    &lt;<span class="keywordtype">url-pattern</span>&gt;/<span class="keyword">org.dbcloud.mongodb.MongoCollection</span>&lt;/<span class="keywordtype">url-pattern</span>&gt;</div><div class="line">&lt;/<span class="keywordtype">servlet-mapping</span>&gt; </div></div><!-- fragment --></li>
<li>Edit your html file, you can see the index.html</li>
</ol>
<div class="fragment"><div class="line">﻿&lt;!DOCTYPE html&gt;</div><div class="line">&lt;html&gt;</div><div class="line">    &lt;head&gt;</div><div class="line">    &lt;/head&gt;</div><div class="line">    &lt;body&gt;</div><div class="line">        &lt;div id=&#39;log&#39;&gt;&lt;/div&gt;</div><div class="line">    &lt;/body&gt;</div><div class="line">    &lt;script src=&quot;js/json2.js&quot; note=&#39;for IE6.0 ,old browser&#39;&gt;&lt;/script&gt;</div><div class="line">    &lt;script src=&quot;js/jQuery-1.12.4.min.js&quot; note=&#39;for IE6.0 ,new version can use JQuery 2.x&#39;&gt;&lt;/script&gt;</div><div class="line">    &lt;script src=&quot;js/org.dbcloud.mongodb.MongoCollection.js&quot;&gt;&lt;/script&gt;</div><div class="line">    &lt;script&gt;</div><div class="line">        try {</div><div class="line">            function log(msg) {</div><div class="line">                $(&quot;#log&quot;).append(&quot;&lt;p&gt;&quot; + msg + &quot;&lt;/p&gt;&quot;);</div><div class="line">            }</div><div class="line">            var table = new org.dbcloud.mongodb.MongoCollection();</div><div class="line">            log(&quot;clear table&quot;);</div><div class="line">            table.deleteMany({});</div><div class="line">            log(&quot;insertOne and set options&quot;);</div><div class="line">            table.insertOne({name: &#39;validation&#39;}, {validation: true});</div><div class="line">            log(&quot;count:&quot; + table.count({index: {&#39;$exists&#39;: true}}));</div><div class="line">            var data = table.find({&#39;index&#39;: {&#39;$gt&#39;: 5}}, {projection: {&#39;_id&#39;: 0}});</div><div class="line">            log(&quot;find index &gt; 5 and exclude _id column&quot;);</div><div class="line">            log(JSON.stringify(data));</div><div class="line">            log(&quot;replaceOne&quot;);</div><div class="line">            table.replaceOne({name: &#39;dbcloud&#39;}, {name: &#39;replace&#39;, status: 0});</div><div class="line">            log(&quot;updateMany with options &quot;);</div><div class="line">            table.updateMany({&#39;index&#39;: {&#39;$gt&#39;: 10}}, {&#39;$set&#39;: {name: &#39;updateMany&#39;, status: 100, index: 100}}, {upsert: true, validation: false});</div><div class="line">            log(&quot;find all&quot;);</div><div class="line">            var data = table.find();</div><div class="line">            log(JSON.stringify(data));</div><div class="line">            log(&#39;findOneAndUpdate&#39;);</div><div class="line">            log(JSON.stringify(table.findOneAndUpdate({&#39;index&#39;: {&#39;$gt&#39;: 10}}, {&#39;$set&#39;: {name: &#39;findOneAndUpdate&#39;}, &#39;$inc&#39;: {index: -1}})));</div><div class="line">            table.close();</div><div class="line">        } catch (e) {</div><div class="line">            alert(e.message);</div><div class="line">        }</div><div class="line">    &lt;/script&gt;</div><div class="line">&lt;/html&gt;</div></div><!-- fragment --> </div></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="index.html">Development Manual</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
</body>
</html>
